package com.ztx.jpaSpring.dao;

import com.ztx.jpaSpring.entity.Person;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * PersonDao--jpa-Demo
 *
 * @author: Jovi
 * @createTime: 2018-08-09 16:33
 **/
@Repository
public class PersonDao {

    /**
     * 如何获取到和当前事务关联的EntityManager 对象
     */
    @PersistenceContext
    private EntityManager entityManager;

    public void save(Person person) {
        entityManager.persist(person);
    }
}
